﻿using System.Collections.ObjectModel;
using GalaSoft.MvvmLight;
using Looptribe.Moodlin8.Model;

namespace Looptribe.Moodlin8.ViewModel
{
    public class CourseContentViewModel : ViewModelBase
    {
        private bool _isLoading;

        public bool IsLoading
        {
            get { return _isLoading; }
            private set { Set(() => IsLoading, ref _isLoading, value); }
        }

        private CourseContent _content;
        public CourseContent Content
        {
            get { return _content; }
            set { Set(() => Content, ref _content, value); }
        }

        private readonly ObservableCollection<CourseModuleWrapper> _items = new ObservableCollection<CourseModuleWrapper>();
        public ObservableCollection<CourseModuleWrapper> Items { get { return _items; }}

        // TODO: bind something better...
        public object Group { get; set; }

        public CourseContentViewModel()
        {
        }

        public void LoadContent(CourseContent content)
        {
            _content = content;
            _items.Clear();
            foreach (var module in _content.Modules)
                _items.Add(new CourseModuleWrapper(module));
        }
    }
}
